<template>
	<view>
		<!-- 头部背景 -->
		<view class="headCss"></view>

		<!-- 控制面板 -->
		<view class="headText2">
			<!-- 使用 Flex 布局使文字和输入框水平对齐 -->
			<view class="input-group">
				<text class="myText">输入核销码</text>
				<input type="text" class="myInput" v-model="verifyCode" />
				<button class="identify-btn" @click="handleIdentify">识别</button>
			</view>
		</view>

		<view v-if="isSearch">
			<!-- 控制面板 -->
			<view class="headText">
				<view class="divText1">核销码 {{code}}</view>
				<!-- 分割线 -->
				<view class="div-line" />
				<!-- 服务内容 -->
				<view class="serve-order">
					<text>
						服务内容
					</text>
					<text>{{serveName}}</text>
					<text v-for="(item,index) in serve" :key="index">{{item}}</text>
					<text>（{{serveRemark}}）</text>
				</view>
				<!-- 分割线 -->
				<view class="div-line" />
				<view class="serve-order">
					<text>
						订单信息
					</text>
					<text>订单价格：￥{{orderPrice}}</text>
					<text>实付金额：<text style="display: inline; font-weight: bold;">￥{{payPrice}}</text></text>
					<text>优惠金额：￥{{preferentialPrice}}</text>
					<text>订单编号：{{orderId}}</text>
					<text>支付时间：{{payTime}}</text>
					<text>预约时间：{{appointmentTime}}</text>
				</view>
			</view>

			<button v-if="!isUserd" type="primary" @click="dialogToggle('info')"
				style="width: 80%; border-radius: 60rpx; margin-top: 40rpx;">确认核销</button>
			<!-- 关键修改：添加 background-color 和 :disabled="true" -->
			<button v-else
				style="width: 80%; border-radius: 60rpx; margin-top: 40rpx; background-color: #808080; color: #fff;"
				:disabled="true">
				已核销
			</button>

		</view>
		<view>
			<!-- 提示窗示例 -->
			<uni-popup ref="alertDialog" type="dialog">
				<uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="核销此订单"
					content="请您仔细核对订单，此操作不可撤销，请谨慎操作!" @confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
			</uni-popup>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				verifyCode: '泥嚎',
				isUserd: false,
				isSearch: false,
				code: 'MC1234-5678-9012',
				serveName: "XXX标准洗车服务包含",
				serve: [
					"整车泡沫冲洗擦T",
					"轮胎轮毂冲洗清洁",
					"车内吸尘",
					"内饰脚垫简单除尘"
				],
				serveRemark: "不包含虫蛀、水泥、沥青和顽固污渍清理等",

				orderPrice: 30.00, // 订单金额
				payPrice: 25.00, // 实付金额
				preferentialPrice: 5.00, // 优惠金额
				orderId: 2025090510434893849, // 订单编号
				payTime: "2025-03-25 10:00:00", // 支付时间
				appointmentTime: "2025-03-25 14:00:00", // 预约时间
			};
		},
		methods: {
			handleIdentify() {
				// 点击“识别”按钮的逻辑
				console.log('识别核销码:', this.verifyCode);
				this.isSearch = true
			},
			dialogToggle(type) {
				this.$refs.alertDialog.open(this.type)
			},
			dialogConfirm() {
				console.log('点击确认')
				this.isUserd = true
			},
			dialogClose() {
				console.log('点击关闭')
			},
		}
	};
</script>

<style scoped>
	.headCss {
		background-color: #3385fd;
		width: 750rpx;
		height: 300rpx;
		position: fixed;
	}

	.headText2 {
		background-color: #fff;
		border-radius: 20rpx;
		width: 690rpx;
		height: 130rpx;
		margin-left: 20rpx;
		position: relative;
		padding-top: 40rpx;
		padding-left: 20rpx;
	}

	.headText {

		margin-top: 20rpx;
		background-color: #fff;
		border-radius: 20rpx;
		width: 710rpx;
		min-height: 400rpx;
		margin-left: 20rpx;
		position: relative;
	}

	/* 输入框和文字的容器，使用 Flex 布局 */
	.input-group {
		display: flex;
		align-items: center;
		/* 垂直居中 */
		overflow: hidden;
		/* 隐藏溢出内容 */
	}


	.divText1 {
		text-align: center;
		font-size: larger;
		padding-top: 20rpx;
	}



	/* 分割线 */
	.div-line {
		width: 670rpx;
		margin: 20rpx 20rpx 20rpx 20rpx;
		height: 10rpx;
		background-color: #f7f7f7;
		border-radius: 10rpx;
	}

	.serve-order>text {
		display: block;
		padding: 10rpx 10rpx 10rpx 20rpx;
	}

	.serve-order>text:nth-child(1) {
		font-size: large;
		font-weight: bold;
	}

	.serve-order>text:last-child {
		padding-bottom: 20rpx;
	}

	.myText {
		line-height: 80rpx;
		height: 80rpx;
		color: #3385fd;
		padding-right: 10rpx;
		font-size: large;
	}

	.myInput {
		flex: 1;
		/* 输入框占满剩余空间 */
		height: 80rpx;
		border: 1rpx solid #bdbdbd;
		border-radius: 40rpx 0rpx 0rpx 40rpx;
		padding-left: 40rpx;
	}

	/* 识别按钮 */
	.identify-btn {
		width: 100rpx;
		height: 80rpx;
		line-height: 80rpx;
		margin-right: 20rpx;
		background-color: #3385fd;
		color: #fff;
		border: none;
		border-radius: 0 40rpx 40rpx 0;
		font-size: 20rpx;
	}
</style>